<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<title>txtSQL Documentation</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<link rel="stylesheet" type="text/css" href="./includes/style.css" />
	<script src="./includes/javascript.js"></script>
</head>
<body>

<table width="96%" cellspacing="0" cellpadding="9" border="0" align="center" class="mainTable">
	<tr>
		<td class="header" colspan="2">
			<table cellspacing="0" cellpadding="0" border="0" width="100%">
				<tr>
					<td align="left">
						<a href="index.html">Home</a>
						&nbsp; &nbsp;<a href="javascript:history.back()">Back</a>
						&nbsp; &nbsp;<a href="javascript:history.forward()">Forward</a>
						&nbsp; &nbsp;<a href="javascript:location.reload()">Refresh</a>
						&nbsp; &nbsp;<a href="http://chibiguy.dotgeek.org/index.php">txtSQL Homepage</a>
					</td>
					<td align="right">
						<a href="http://chibiguy.dotgeek.org/index.php" target="_blank"><img src="includes/txtsql_powered_small.gif" /></a>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr valign="top">
		<td class="mainCell">
			<div class="dashedUnderline"><a href="index.html">txtSQL Documentation</a> > <a  href="7.html">SQL Syntax</a> > SELECT Syntax</div><br />

			<table width="100%">
				<tr valign="bottom">
					<td align="left">
						<div class="h1">SELECT Syntax </div>
					</td>
					<td align="right">
						txtSQL >= 3.0.0 Beta					</td>
				</tr>
			</table>

			<br />			<div class="content">
				<font color="blue"><b>SELECT</b></font >( <i>* | [column1, column2</i>...[ <font color="blue">AS</font> alias...]])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [ <font color="blue">DISTINCT</font> <i>column</i>]<br /><br/>
<font color="blue"><b>FROM</b></font> (<i>db.table|table</i>)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [ <font color="blue">WHERE</font> <font color="firebrick"><i>WhereClause</i></font><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [ <font color="blue">LIMIT</font> <font color="firebrick"><i>LimitClause</i></font><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [ <font color="blue">ORDERBY</font> <font color="firebrick"><i>OrderByClause</i></font>]]]<br /><br />

The SELECT statement will retrieve data that matches the <a  href="8.html">WHERE clause</a>; if no WHERE clause is given, all rows match, and thus, all will be returned. In order to select only certain columns, specify the respective columns right after the 'SELECT' (For example: SELECT id, name, adress ...).<br /><br />

You may also specify column aliases after the column name when selecting ("SELECT id as IDENT, name AS NAME"). Also, instead of column names, you may also select string literals or computations, although a bit limited in it's capability (For example: "SELECT id, 'some random text' as RANDOM, eval(1+1) as TWO")<br /><br />

The search will take place inside the selected database, unless you specify a database along with the table after the 'FROM' part (For Example: SELECT * FROM db.table). Furthermore, only the rows that fall into the LIMIT will be returned.<br /><br />

If an <a  href="11.html">ORDERBY statement</a> is given, then the results will be sorted according to the orderby clause. Please make note that this operation is expensive on larger SELECT's in terms of timing and should be used sparingly. If a DISTINCT statement is given for a column, then all rows that contain a duplicate of that respective column will NOT be returned.<br /><br />

<B>NOTE</B>- To have a complete look at the SELECT function, and any changes to its functionality, see the <a  href="29.html">select() function</a>.			</div><br /><br />

			
			
			<TEXTAREA ID="holdtext" STYLE="display: none;"></TEXTAREA>			
			<table class="commentTable">
				<tr>
					<td style="border: 0px solid; margin: 0px; padding: 0px;">
						<table width="100%">
							<tr>
								<td style="border:0px solid;">
									<div class="h1">User Comments - SELECT Syntax</div>
								</td>
								<td align="right" style="border: 0px solid; padding: 0px; margin: 0px;">
									
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="row1" align="center">
						No comments posted yet; 
					</td>
				</tr>
			</table>
		</td>

		<td class="sideCell">
		
			<table width="100%" cellspacing="0" cellpadding="0" border="0" class="dashedUnderline">
				<tr>
					<td align="left">
						<a  href="52.html">Last Page</a>					</td>
					<td align="right">
						<a  href="54.html">Next Page</a>					</td>
				</tr>
			</table><br />

			
			<a style="font-weight: bold;"  href="1.html">'Language Reference'</a></b><br />
			<br />

			<a style="font-weight: bold;"  href="13.html">User Functions</a></b><br />
			<br />

			<a style="font-weight: bold;"  href="19.html">Database Functions</a></b><br />
			<br />

			<a style="font-weight: bold;"  href="28.html">Data Manipulation Functions</a></b><br />
			<br />

			<a style="font-weight: bold;"  href="34.html">Table Functions</a></b><br />
			<br />

			<a style="font-weight: bold;"  href="42.html">Error Handling Functions</a></b><br />
			<br />

			<a style="font-weight: bold;"  href="52.html">SQL Syntax</a></b><br />
			<li /> <i>SELECT Syntax</i><br />
			<li /> <a  href="54.html">INSERT Syntax</a><br />
			<li /> <a  href="55.html">DELETE syntax</a><br />
			<li /> <a  href="56.html">UPDATE Syntax</a><br />
			<li /> <a  href="57.html">CREATE DATABASE Syntax</a><br />
			<li /> <a  href="58.html">DROP DATABASE Syntax</a><br />
			<li /> <a  href="59.html">SHOW DATABASES Syntax</a><br />
			<li /> <a  href="60.html">USE Syntax</a><br />
			<li /> <a  href="61.html">LOCK Syntax</a><br />
			<li /> <a  href="62.html">UNLOCK Syntax</a><br />
			<li /> <a  href="63.html">IS LOCKED Syntax</a><br />
			<li /> <a  href="64.html">CREATE TABLE Syntax</a><br />
			<li /> <a  href="65.html">DROP TABLE Syntax</a><br />
			<li /> <a  href="66.html">SHOW TABLES Syntax</a><br />
			<li /> <a  href="67.html">DESCRIBE Syntax</a><br />
			<li /> <a  href="68.html">SHOW USERS Syntax</a><br />
			<li /> <a  href="69.html">GRANT PERMISSIONS Syntax</a><br />
			<li /> <a  href="70.html">Column Properties</a><br />
			<li /> <a  href="71.html">Column Types</a><br />
			<li /> <a  href="72.html">LIMIT Syntax</a><br />
			<li /> <a  href="73.html">ORDERBY Syntax</a><br />
			<li /> <a  href="74.html">WHERE Syntax</a><br />
			<br />

		</td>
	</tr>
	<tr>
		<td colspan="2" class="notices" align="center">
			[ txtSQL Documentation powered by <a href="http://chibiguy.dotgeek.org" target="_blank">txtSQL</a> | 6 SQL Queries ]
		</td>
	</tr>
</table>

</body>
</html>